﻿<Window x:Class="Utilities.ColorDialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Utilities" 
    Title="Select Color" 
    SizeToContent="Height"
    Width="250" 
    WindowStartupLocation="CenterOwner"
    ResizeMode="NoResize"
    ShowInTaskbar="False"
    WindowStyle="ToolWindow"
    >
    
    <Window.Resources>
        <local:DoubleToIntegerConverter x:Key="conv" Min="0" Max="255"/>

        <SolidColorBrush x:Key="DialogBackgroundBrush" Color="{x:Static SystemColors.ControlColor}" />

        <Style TargetType="Button">
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="Padding" Value="10,3,10,3"/>
            <Setter Property="Margin" Value="5,10,5,10"/>
            <Setter Property="MinWidth" Value="80" />
        </Style>

        <Style TargetType="TextBlock" x:Key="ValueTextBlockStyle">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Margin" Value="3"/>
            <Setter Property="TextAlignment" Value="Right"/>
        </Style>

        <Style TargetType="TextBlock" x:Key="LabelTextBlockStyle">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Margin" Value="5,3,5,3"/>
        </Style>

        <Style TargetType="Slider">
            <Setter Property="SmallChange" Value="1" />
            <Setter Property="LargeChange" Value="1" />
            <Setter Property="Minimum" Value="0" />
            <Setter Property="Maximum" Value="255" />
            <Setter Property="Margin" Value="0,3,0,3" />
        </Style>

    </Window.Resources>
    
    <Grid Background="{StaticResource DialogBackgroundBrush}">
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>

        <Grid Grid.Row="0">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="10*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
            </Grid.ColumnDefinitions>


            <TextBlock Grid.Row="0" Grid.Column="0" Text="R"
                       Style="{StaticResource LabelTextBlockStyle}"
                       />

            <Slider Grid.Row="0" Grid.Column="1" Name="sliderR" />

            <TextBlock Grid.Row="0" Grid.Column="2"
                    Style="{StaticResource ValueTextBlockStyle}"
                    Text="{Binding ElementName=sliderR, Path=Value, Mode=OneWay, Converter={StaticResource conv}}"
                       />

            <TextBlock Grid.Row="1" Grid.Column="0" Text="G"
               Style="{StaticResource LabelTextBlockStyle}"
                       />

            <Slider Grid.Row="1" Grid.Column="1" Name="sliderG" />

            <TextBlock Grid.Row="1" Grid.Column="2"
                    Style="{StaticResource ValueTextBlockStyle}"
                    Text="{Binding ElementName=sliderG, Path=Value, Mode=OneWay, Converter={StaticResource conv}}"
                       />

            <TextBlock Grid.Row="2" Grid.Column="0" Text="B"
                    Style="{StaticResource LabelTextBlockStyle}"
                       />

            <Slider Grid.Row="2" Grid.Column="1" Name="sliderB" />

            <TextBlock Grid.Row="2" Grid.Column="2"
                    Style="{StaticResource ValueTextBlockStyle}"
                    Text="{Binding ElementName=sliderB, Path=Value, Mode=OneWay, Converter={StaticResource conv}}"
                       />

            <TextBlock Grid.Row="3" Grid.Column="0" Text="A"
           Style="{StaticResource LabelTextBlockStyle}"
                       />

            <Slider Grid.Row="3" Grid.Column="1" Name="sliderA" />

            <TextBlock Grid.Row="3" Grid.Column="2"
                    Style="{StaticResource ValueTextBlockStyle}"
                    Text="{Binding ElementName=sliderA, Path=Value, Mode=OneWay, Converter={StaticResource conv}}"
                       />

            <Border Name="borderSample"  Grid.Row="0" Grid.Column="3" Grid.RowSpan="4"
                    BorderThickness="1" BorderBrush="Black" CornerRadius="3"
                    Margin="5"
                    />
        </Grid>

        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <Button Grid.Column="0" Name="buttonOK"  IsDefault="True">
                OK
            </Button>
            <Button Grid.Column="1" IsCancel="True">
                Cancel
            </Button>

        </Grid>
        
    </Grid>
</Window>
